<%@ page language="java" import="java.sql.*"
	contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>


<%!
	public Connection cOpen() throws SQLException {
		Connection con = null;
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			con = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=webrac2)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=LCCD_APP.DCC.COM)))", "DISCOUNT_USER", "user_0f_discount");
			
		} catch (Exception e) {
			//out.println("Connection :: " + e.getMessage());
			e.printStackTrace(System.out);
		}
		return con;
	}

    public String replaceNull(String str){
	  return ((str== null) ? "" : str);
	}
   
%>

<%
	Connection con = null;
	Statement stmt = null;
	ResultSet rs = null;
	String SQL = "";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Commission Junction Deals</title>
<style>
table
{
margin:0;
padding:0;
}
th
{
white-space:pre;
background-color:#dddddd;
text-align:left
}
</style>
</head>
<body>
<table>
	<tr>
		<th align="left">Advertiser Name</th>
		<th>Buy Url</th>
		<th>Currency</th>
		<th>Image URL</th>
		<th>In Stock</th>
		<th align="left">ISBN </th>
		<th align="left">Manufacturer Name</th>
		<th align="left">Manufacturer SKU</th>
		<th>Price</th>
		<th>Retail Price</th>
		<th>Sale Price</th>
		<th align="left">SKU</th>
		<th>UPC</th>
		<th align="left">Advertiser Category</th>
		<th align="left">Name</th>
		<th align="left">Description</th>
		<th>Ad-Id</th>
		<th>Advertiser Id</th>
		<th>Catalog Id</th>

	</tr>
	<%
		try {
			con = cOpen();
			SQL = "SELECT ADVERTISER_NAME,BUY_URL,CURRENCY,IMAGE_URL,IN_STOCK,ISBN,MANUFACTURER_NAME,MANUFACTURER_SKU,PRICE,RETAIL_PRICE,SALE_PRICE,SKU,UPC,ADVERTISER_CATEGORY,NAME,DESCRIPTION,AD_ID,ADVERTISER_ID,CATALOG_ID FROM DISCOUNTS_CJ"; 			 
			stmt = con.createStatement();
			rs = stmt.executeQuery(SQL);
			while (rs.next()){
	%>
	<tr>
		        <td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(1))%></td>
		        <td align="left" nowrap="nowrap"><a href="<%=replaceNull(rs.getString(2))%>" target="_blank">Details</a></td>
		        <td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(3))%></td>
		        <td align="left" nowrap="nowrap"><a href="<%=replaceNull(rs.getString(4))%>" target="_blank">Details</a></td>
		        <td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(5))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(6))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(7))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(8))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(9))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(10))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(11))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(12))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(13))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(14))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(15))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(16))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(17))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(18))%></td>
				<td align="left" nowrap="nowrap"><%=replaceNull(rs.getString(19))%></td>
	</tr>
	<%
		}
		} catch (SQLException e) {
			out.println("Connection :: " + e.getMessage());
		} finally {
			try {
				stmt.close();
			} catch (Exception e) {
			}
			try {
				rs.close();
			} catch (Exception e) {
			}
			try {
				if (null != con) {
					con.close();
				}
			} catch (SQLException ex) {
				out.println("Connection :: " + ex.getMessage());
			}
		}
	%>
</table>
</body>
</html>